<?php
require_once("classes/page.class.php");
require_once("classes/adrese.class.php");
function aboutUs(){
	$page = new page("about.tpl");
	$adresa = new adrese();
	
	$id 	= "29429";
	$regbr	= "01317323776";
	$pdv	= "134108087";
	
	
	
	$q = "SELECT komitent_name, komitent_name1, komitent_adresa, komdel_adresa_id, komitent_matbr, komitent_pib, delatnost_ime "
		."FROM komitenti, komitenti_delatnosti, delatnosti "
		."WHERE komitenti.komitent_id=komitenti_delatnosti.komdel_kom_id "
		."AND komdel_del_id=delatnost_id "
		."AND komitent_id=$id";
	
	$res = $page->db->select2($q);
	
	if($res !== false){
		
		foreach ($res as $k=>$row){
			$data["name"]	= $row["komitent_name"];
			$data["name1"]	= $row["komitent_name1"];
			$data["sediste"]= $row["komitent_adresa"];
			$data["adrese"][] = $row["komdel_adresa_id"];
			$data["matbr"]		= $row["komitent_matbr"];
			$data["pib"]		= $row["komitent_pib"];
			$data["delatnosti"][]= $row["delatnost_ime"];
			
			// telefoni faxevi
			$q = "SELECT telefon,fax FROM komitenti_telefoni WHERE kom_id=$id";
			$tels = $page->db->select2($q);
			if($tels !== false){
				foreach ($tels as $tel){
					if($tel["fax"]==1){
						$data["fax"][] = $tel["telefon"];
					}else{
						$data["telefon"][] = $tel["telefon"];
					}
				}
			}
			// emails
			$q = "SELECT DISTINCT email FROM komitenti_emails WHERE kom_id=$id";
			$mails = $page->db->select2($q);
			if($mails !== false){
				foreach ($mails as $mail){
					$data["email"][] = $mail["email"];
				}
			}
			// webs
			$q = "SELECT DISTINCT web FROM komitenti_webs WHERE kom_id=$id";
			$webs = $page->db->select2($q);
			if($webs !== false){
				foreach ($webs as $web){
					$data["web"][] = $web["web"];
				}
			}
			
			// ziro_racuni
			$q = "SELECT ziro_value, banka_name FROM komitenti_ziro_racuni, banke WHERE ziro_komitent_id=$id AND ziro_banka_id=banka_id";
			$zrs = $page->db->select2($q);
			if($zrs !== false){
				foreach ($zrs as $zr){
					$data["ziro"][] = $zr["banka_name"].": ".$zr["ziro_value"];
				}
				$data["ziro"] = array_unique($data["ziro"]);
			}
			
			
		}
		$data["adrese"] = array_unique($data["adrese"]);
		$data["telefon"] = array_unique($data["telefon"]);
		$data["fax"] = array_unique($data["fax"]);
		$data["email"] = array_unique($data["email"]);
		$data["web"] = array_unique($data["web"]);
		
		$adr = $adresa->getAll($data["sediste"]);
		$data["sediste"] = $adr["ulica"]." ".$adr["broj"];
		foreach ($data["adrese"] as $k=>$adrid){
			$adr = $adresa->getAll($adrid);
			if($adr !== false){
				$data["adrese"][$k] = $adr["ulica"]." ".$adr["broj"];
			}else{
				unset($data["adrese"][$k]);
			}
		}
		
		
		
		$page->assign("ime_firme",$data["name"]);
		$page->assign("ime_firme_full",$data["name1"]);
		$page->assign("adresa",$data["sediste"]);
		$page->assign("adresaPTT",@implode("<br />",$data["adrese"]));
		$page->assign("tel",@implode("<br />",$data["telefon"]));
		$page->assign("fax",@implode("<br />",$data["fax"]));
		$page->assign("mail",@implode("<br />",$data["email"]));
		$page->assign("web",$data["web"]);
		$page->assign("ziro",@implode("<br />",$data["ziro"]));
		$page->assign("matbr",$data["matbr"]);
		$page->assign("pib",$data["pib"]);
		$page->assign("regbr",$regbr);
		$page->assign("pdv",$pdv);
		$page->assign("delatnost",@implode("<br />",$data["delatnosti"]));
		
		
		echo $page->parseTemplate("about.tpl");
	}else{
		echo "Nema komitenta pod šifrom $id";
	}
}
?>